#include "SearchAndReplace.h"

#include <QDebug>

SearchAndReplace::SearchAndReplace(QWidget* parent) : QDialog(parent), ui(new Ui_SearchAndReplace) {
    ui->setupUi(this);
}

SearchAndReplace::~SearchAndReplace() { delete ui; }

void SearchAndReplace::on_LastPushButton_clicked() {
    qDebug() << "on_LastPushButton_clicked!";
    emit searchInfo(ui->SearchLineEdit->text(), SearchDir::LAST);
}

void SearchAndReplace::on_NextPushButton_clicked() {
    qDebug() << "on_NextPushButton_clicked!";
    emit searchInfo(ui->SearchLineEdit->text(), SearchDir::NEXT);
}

void SearchAndReplace::on_ReplaceButton_clicked() {
    qDebug() << "on_ReplaceButton_clicked!";
    emit replaceInfo(ui->SearchLineEdit->text(), ui->ReplaceLineEdit->text(), ReplaceType::ONCE);
}

void SearchAndReplace::on_ReplaceAllButton_clicked() {
    qDebug() << "on_ReplaceAllButton_clicked!";
    emit replaceInfo(ui->SearchLineEdit->text(), ui->ReplaceLineEdit->text(), ReplaceType::ALL);
}

void SearchAndReplace::showEvent(QShowEvent* event) {
    qDebug() << "showEvent!";
    ui->SearchLineEdit->clear();
    ui->ReplaceLineEdit->clear();
}
